<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title></title>
    <link rel="stylesheet" type="text/css" href="../css/usercenter/center.css">
    <script src="../js/jquery-1.8.3.min.js"></script>
    <script type="text/javascript">
        $(function () {
            var account = window.sessionStorage.getItem("account");
            //页面打开后,自动向servlet发送请求 查询用户个人信息
            $.get("../login/findUserMsg",{account:account},function (res) {
                console.log(res);
                $("input[name='nickname']").val(res.data.nickname)
                $("input[name='mailbox']").val(res.data.mailbox)
                $("input[name='phone']").val(res.data.phone)
                if (res.data.sex == '男') {
                    $("input[value='男']").attr("checked", true);
                } else {
                    $("input[value='女']").attr("checked", true);
                }
                $("input[name='address']").val(res.data.address)
            }, "json");
        })
        function update(){
            $.post("../login/updateMsg",$("#formId").serialize(),function(res){
                console.log(res)
                if(res.code==202){
                    window.parent.location.replace("../back/index.html");
                }else if(res.code==500){
                    alert("服务器忙,请稍后再试!");
                }else{
                    alert("保存成功!");
                }
            });
        }
    </script>
</head>
<body>
<div class="public_m1">
    <div class="public_m2">资料管理</div>
    <!--照片和内容-->
    <div class="zp_nrm">
        <!--left-->
        <div class="zp_nrm_l">
            <img src="../img/usercenter/user.png">
        </div>
        <!--right-->
        <form id="formId">
            <input type="hidden" id="accountId" name="account"/>
            <div class="zp_nrm_r">
                <p><em>昵称：</em><input type="text" name="nickname"></p>
                <p><em>邮箱：</em><input type="text" name="mailbox"></p>
                <p><em>手机号：</em><input type="text" name="phone"></p>
                <p><em>性别：</em><input type="radio" name="sex" class="sex_m" value="男"><i>男</i>
                    <input type="radio" name="sex" class="sex_m" value="女"><i>女</i></p>
                <p><em>地址：</em><input type="text" name="address"></p>
                <a class="public_m3" onclick="update()">保存修改</a>
            </div>
        </form>
    </div>
</div>
</body>
</html>
